<?php
	include_once("inc/global_init.php");
	session_start();
	
	$id = $_GET['id'];
	$id = strip_tags($id);
	
	do_html_header('Linker Loader');
	goUrlScript();

	$conn = db_connect();
	$sql = "SELECT * FROM link_url u, link_cat c WHERE u.urlCat = c.catID AND u.urlID = ".$id." AND c.catUser = '".$_SESSION['valid_user']."'";
	$result = $conn->query($sql);

if($result->num_rows == 1)
{
	$row = $result->fetch_array();
	
	$dt = date("Y.m.d H:i:s");
	$ip=$_SERVER['REMOTE_ADDR']; 
	$InsertStatement = "INSERT INTO `link_log` (`urlID`,`urlName`,`urlAddr`,`urlCat`,`catID`,`catName`,`catLeft`,`catTop`,`catColor1`,`catColor2`,`type`,`catWidth`,`user`,`datetime`,`ipaddr`,`session`) VALUES('"
		.$row['urlID']."', '"
		.$row['urlName']."', '"
		.$row['urlAddr']."', '"
		.$row['urlCat']."', '"
		.$row['catID']."', '"
		.$row['catName']."', '"
		.$row['catLeft']."', '"
		.$row['catTop']."', '"
		.$row['catColor1']."', '"
		.$row['catColor2']."', '"
		.$row['type']."', '"
		.$row['catWidth']."','"
		.$_SESSION['valid_user']."','"
		.$dt."','"
		.$ip."','"
		.session_id()."');";
	$conn->query($InsertStatement);
	
	$link = $row['urlAddr'];
	goUrl($link);
}
else
{
	goUrl(WEB_HOME);
}


	do_html_footer();

?>
